
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.game.GameCanvas;
//import javax.microedition.lcdui.

class VeMeNu extends GameCanvas{
            
    int rong=getWidth();
    int cao=getHeight();
    Image menu=Image.createImage(rong,cao);;
    Font font,fontdam;
    CellMeNu mangmenu[]=new CellMeNu[4];    
    Graphics g=menu.getGraphics();
    Graphics g1=getGraphics(); //graphic man hinh
    //Main dis=;
    
    VeMeNu()
    {        
        super(true);
        Ve();
        g1.drawImage(menu, 0, 0, Graphics.TOP|Graphics.LEFT);
        flushGraphics();
        
    }
   // public void paint(Graphics g2)
  //  {
                
        
        //flushGraphics();
  //  }
    void Ve()
    {

       
       font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_SMALL );
       fontdam=Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE);
       
       
       //nền
       g.setColor(0xfffdd6);
       g.fillRect(0, 0, rong, cao); 
       g.setColor(0x3db2d8);
       g.setFont(fontdam);
       g.drawString("FITHOU EDU", rong/2, 2, Graphics.TOP|Graphics.HCENTER);
       g.setFont(font);
      
       g.setColor(0x3db2d8);
       g.drawString("Xin chào: Bùi Thanh Minh", rong/2, 40, Graphics.TOP|Graphics.HCENTER );
       mangmenu[0]=new CellMeNu("Lịch học",200,30,Mau.mauxanh,Mau.maudo,0xffd000,10,10);
       mangmenu[0].VeCellMeNu(g, (rong-200)/2, 80);
       mangmenu[1]=new CellMeNu("Xem điểm", 200, 30, Mau.mauxanh, Mau.maudo, Mau.maudacam, 10, 10);
       mangmenu[1].VeCellMeNu(g, (rong-200)/2, 120);
       mangmenu[2]=new CellMeNu("Thông báo", 200, 30, Mau.mauxanh, Mau.maudo, Mau.maudacam, 10, 10);
       mangmenu[2].VeCellMeNu(g, (rong-200)/2, 160);
       mangmenu[3]=new CellMeNu("Thoát", 200, 30, Mau.mauxanh, Mau.maudo, Mau.maudacam, 10, 10);
       mangmenu[3].VeCellMeNu(g, (rong-200)/2, 200);       
       mangmenu[1].FocusMeNu(g);
       
       
       
    }
    public void keyPressed(int k){  
    //g=menu.getGraphics();
    int a=getGameAction(k);
 //   int vitrifocus=0;
 //   for(int i=0;i<4;i++)
//    {
//       if(mangmenu[i].IsFocus==1)
//        {
//            vitrifocus=i;
//        }
//    }
    if(a==UP)
    {
      // if(vitrifocus>0)
      // {
        mangmenu[2].FocusMeNu(g);
        g1.drawImage(menu, 0, 0, Graphics.TOP|Graphics.LEFT);
        flushGraphics();
       // flushGraphics();
          // mangmenu[1].UnFocusMeNu(g);
           //Graphics gra=getGraphics();
          // gra.setColor(0x000000);
          // gra.drawRect(0, 0, getWidth(), getHeight());
          // flushGraphics();
          // g1.drawImage(menu, 0, 0, Graphics.TOP|Graphics.LEFT);
           //flushGraphics();
           //repaint();
           
           //Main.display.setCurrent(Main.dangnhap);
           //g1.drawImage(man, 0, 0, Graphics.TOP|Graphics.LEFT);
        
      // }
    }
    if(a==DOWN)
    {
       // if(vitrifocus<4)
       // {
        //  mangmenu[vitrifocus+1].FocusMeNu(g);   
       // }
    }
    }
} 
class DangNhap implements CommandListener{

    public void commandAction(Command c, Displayable d) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    
}
public class Main extends MIDlet implements CommandListener{
    public static Display display;
    public static Form dangnhap=new Form("Thông Tin Đăng Nhập");
    

    void fdangnhap(){
        TextField taikhoan=new TextField("Tài khoản:", null, 20, TextField.ANY);
        TextField matkhau=new TextField("Mật Khẩu:", null, 20, TextField.PASSWORD);
        Command cmdDangnhap=new Command("Đăng nhập",Command.OK, 1);
        Command cmdThoat=new Command("Thoát",Command.EXIT, 0);
        dangnhap.append(taikhoan);
        dangnhap.append(matkhau);
        dangnhap.addCommand(cmdDangnhap);
        dangnhap.setCommandListener(this);
        dangnhap.addCommand(cmdThoat);
    }
    public void startApp() {
        display=Display.getDisplay(this);
        //fdangnhap();
        //Display.getDisplay(this).setCurrent(dangnhap);
     //   display.setCurrent(dangnhap);
        display.setCurrent(new XemDiem());
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        String label=c.getLabel();
        if(label.equals("Đăng nhập"))
          
        {
            display.setCurrent(new VeMeNu());
//            Alert tbdn=new Alert("FITHOU EDU", "Sai tài khoản hoặc mật khẩu. Xin hãy thử lại!", null, AlertType.ERROR);
//            tbdn.setTimeout(Alert.FOREVER);
//            display.setCurrent(tbdn,dangnhap);
            
        }
        else
            if(label.equals("Thoát"))
            {
             notifyDestroyed();   
            }
    }
}
